#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int score[100005] = {0};
	cin >> n;
	int school,point;
	for(int i = 0;i < n;i++){
		cin >> school >> point;
		score[school] += point;
	}
	int maxi = 1;
	for(int i = 2;i < n;i++){
		if(score[i]>score[maxi]){
			maxi = i;
		}
	}
	cout << maxi << " " << score[maxi];
	return 0;
}
